package com.molichuxing.services.property;

public enum PaymentChannelEnum {

    /**
     * 微信
     */
    WXPAY(1, "微信支付"),

    /**
     * 支付宝
     */
    ALIPAY(2, "支付宝"),

    /**
     * 银联
     */
    UNIONPAY(3, "银联"),

    /**
     * 大屏
     */
    AIOPAY(4, "智能终端银联");

    private int value;

    private String name;

    PaymentChannelEnum(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public int getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    /**
     * 通过value获取枚举的name
     *
     * @param value
     * @return
     */
    public static String getName(int value) {
        for (PaymentChannelEnum payChannelEnum : PaymentChannelEnum.values()) {
            if (payChannelEnum.getValue() == value) {
                return payChannelEnum.name();
            }
        }
        return null;
    }

    /**
     * 通过枚举名获取枚举类
     *
     * @param enumerate
     * @return
     */
    public static PaymentChannelEnum getEnum(String enumerate) {
        try {
            return Enum.valueOf(PaymentChannelEnum.class, enumerate);
        } catch (Exception e) {

        }
        return null;
    }

    /**
     * 通过value获取枚举
     *
     * @param value
     * @return
     */
    public static PaymentChannelEnum getEnum(int value) {
        for (PaymentChannelEnum enumerate : PaymentChannelEnum.values()) {
            if (enumerate.getValue() == value) {
                return enumerate;
            }
        }
        return null;
    }
}
